package la.iok.hzsvn.lewin.movie.shopmovie.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.shopmovie.model.FeesListParam;
import la.iok.hzsvn.lewin.movie.shopmovie.model.FeesParam;
import la.iok.hzsvn.lewin.movie.shopmovie.model.FeesVo;
import la.iok.hzsvn.lewin.movie.shopmovie.model.PayType;
import la.iok.hzsvn.lewin.movie.shopmovie.service.FeesService;
import la.iok.hzsvn.lewin.mybatis.model.PageParam;
import la.iok.hzsvn.lewin.mybatis.model.PageVo;
import la.iok.hzsvn.lewin.mybatis.model.SortParam;
import la.iok.hzsvn.share.response.ListDataResponse;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("fees")
public class FeesController {
    private final FeesService feesService;
    private static final List<PayType> payTypes = Arrays.asList(new PayType("会员收款",1),new PayType("美团收款",2),
            new PayType("微信收款",3),new PayType("其他平台收款",4),new PayType("其他店铺收款",5));

    public FeesController(FeesService feesService) {
        this.feesService = feesService;
    }

    @PostMapping
    public OperatorResponse save(@RequestHeader Token token, @RequestBody FeesParam param){
        feesService.save(token, param);
        return OperatorResponses.success();
    }

    @PutMapping("{id}")
    public OperatorResponse modify(@RequestHeader Token token, @PathVariable Long id, @RequestBody FeesParam param){
        feesService.modify(token, id, param);
        return OperatorResponses.success();
    }

    @DeleteMapping("{id}")
    public OperatorResponse delete(@RequestHeader Token token, @PathVariable Long id){
        feesService.delete(token, id);
        return OperatorResponses.success();
    }

    @GetMapping
    public SingleDataResponse<PageVo<FeesVo>> page(@RequestHeader Token token, PageParam pageParam, SortParam sortParam, FeesListParam listParam){
        return new SingleDataResponse<>(feesService.page(token, pageParam, sortParam, listParam));
    }

    @GetMapping("payTypes")
    public ListDataResponse<PayType> payTypes(){
        return new ListDataResponse<>(payTypes);
    }
}
